package com.example.easy.Controller;


import com.example.easy.Dto.FoodSafety;
import com.example.easy.Dto.Notice;
import com.example.easy.Service.myservice.FoodSafetyServise;
import com.example.easy.Service.myservice.NoticeServise;
import com.example.easy.Tools.ResultCode;
import com.example.easy.mapper.FoodSafetyMapper;
import com.example.easy.mapper.NoticeMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Scope("prototype")
@RestController
@Api(value = "FoodSafety", description = "食品安全")
@RequestMapping(value = "/foodsafety")

public class FoodSafetyController {


    @Autowired
    FoodSafetyMapper foodSafetyMapper;


    @Autowired
   FoodSafetyServise foodSafetyServise;

    @ApiOperation(value = "增加食品安全信息", notes = "增加食品安全信息")
    @RequestMapping(value = "/insNotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object insFoodSafety(@RequestBody FoodSafety foodSafety) throws IOException {

        return ResultCode.SUCCESS.result(foodSafetyServise.insFoodSafety(foodSafety));

    }

    @ApiOperation(value = "修改食品安全信息", notes = "修改食品安全信息")
    @RequestMapping(value = "/updateFoodSafety", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object updateFoodSafety(@RequestBody FoodSafety foodSafety) throws IOException {

        return ResultCode.SUCCESS.result(foodSafetyServise.updateFoodSafety(foodSafety));

    }

    @ApiOperation(value = "删除食品安全信息", notes = "删除食品安全信息")
    @RequestMapping(value = "/deleteFoodSafety", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object deleteFoodSafety(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(foodSafetyServise.deleteFoodSafety(number));

    }

    @ApiOperation(value = "查看食品安全信息", notes = "查看食品安全信息")
    @RequestMapping(value = "/selectFoodSafety", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectFoodSafety(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(foodSafetyServise.selectFoodSafety(number));

    }

    @ApiOperation(value = "查看所有食品安全信息", notes = "查看所有食品安全信息")
    @RequestMapping(value = "/selectall", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectall() throws IOException {

        return ResultCode.SUCCESS.result(foodSafetyServise.selectall());

    }

}
